/*!
 * \file frtimer.h
 *
 * \brief 时钟管理
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 * 时钟管理函数
 *
 * \version 2.0
 * \author yaohl
 * \date 2014/11/29
 *
 */
#ifndef __FRTIMER_H_
#define __FRTIMER_H_

#include <event2/event.h>
#include <event2/event_struct.h>

/*! @brief 时钟管理 */
typedef struct __st_timer_entry {
    //Frtimer_cmd em_cmd_type;

    //event_callback_fn cb;
    //void *arg;

    struct event  *p_st_event;
    struct timeval st_delay;

    //void *p_userdata;
} Timer_entry;

/*!
 * 初始化时钟管理
 *
 */
int frtimer_init(void);

/*!
 * 生成一个新时钟
 *
 * \param base             (struct event_base *)
 * \param cb               (event_callback_fn)
 * \param arg              (参数)
 * \param tv               (延迟时间)
 *
 * \return struct event *
 *
 */
struct event *frtimer_new(struct event_base *base, event_callback_fn cb, void *arg, const struct timeval *tv);

/*!
 * 增加时钟到evnet
 *
 * \param base             (struct event_base *)
 * \param tv               (struct timeval *)
 *
 * \return evtimer_add的返回值
 *
 */
int frtimer_add(struct event *ev, const struct timeval *tv);

/*******************************************************************************
*  FUNC     :  删除时钟
*  ARGS     :  ev             (struct event *)
*  RTN      :
*  NOTE     :
*******************************************************************************/
//int frtimer_del(struct event *ev);

/*!
 * 时钟重新加载
 *
 * \param ev               (struct event *)
 * \param tv               (延迟时间)
 *
 */
int frtimer_reload(struct event *ev, const struct timeval *tv);

/*!
 * 释放时钟
 *
 * \param base             (struct event_base *)
 *
 */
int frtimer_free(struct event *ev);

/*!
 * 释放时钟管理
 *
 */
void frtimer_destory(void);

#endif
